<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <link href="/static/admin/static/h-ui/css/H-ui.min.css" rel="stylesheet" type="text/css" />
    <link href="/static/admin/static/h-ui.admin/css/H-ui.login.css" rel="stylesheet" type="text/css" />
    <link href="/static/admin/static/h-ui.admin/css/style.css" rel="stylesheet" type="text/css" />
    <link href="/static/admin/lib/Hui-iconfont/1.0.8/iconfont.css" rel="stylesheet" type="text/css" />
    <title>后台登录</title>
</head>
<body>
<input type="hidden" id="TenantId" name="TenantId" value="" />
<div class="loginWraper">
    <div id="loginform" class="loginBox">
        <form class="form form-horizontal" action="{{route('admin.login')}}" method="post" id="loginForm">
            @csrf
            <div class="row cl">
                <label class="form-label col-xs-3"><i class="Hui-iconfont">&#xe60d;</i></label>
                <div class="formControls col-xs-8">
                    <input id="username" name="username" type="text" placeholder="账户" class="input-text size-L" required autocomplete="off" value="admin">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-3"><i class="Hui-iconfont">&#xe60e;</i></label>
                <div class="formControls col-xs-8">
                    <input id="password" name="password" type="password" placeholder="密码" class="input-text size-L" required autocomplete="off" value="admin111">
                    <input id="password1" name="password1" type="hidden"  value="">
                </div>
            </div>
            <div class="row cl">
                <div class="formControls col-xs-8 col-xs-offset-3">
                    <input name="" type="button" class="btn btn-success radius size-L" id="doLogin" value="&nbsp;登&nbsp;&nbsp;&nbsp;&nbsp;录&nbsp;">
                </div>
            </div>
            <input type="hidden" name="timestamp" id='timestamp' value="">
        </form>
    </div>
</div>
<div class="footer">Copyright 你的公司名称</div>
<script type="text/javascript" src="/static/js/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="/static/admin/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="/static/admin/lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript" src="/static/js/jquery.sha1.js"></script>
<script type="text/javascript" src="/static/js/jquery.form.min.js"></script>
<script type="text/javascript" src="/static/admin/static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="/static/admin/lib/layer/2.4/layer.js"></script>
<script>
    $().ready(function($){
        $("#doLogin").click(function(){
            $("#loginForm").validate({
                debug:true
            });

            var username = $("#username").val();
            var password = $.sha1($("#password").val());
            var timestamp = new Date().getTime();
            var _token = '{{csrf_token()}}';

            $.ajax({
                url: '{{route("admin.getsalt")}}',
                type: 'POST',
                dataType: 'json',
                data: {username: username,_token:_token},
                success:function(e){
                    $("#timestamp").val(timestamp)
                    $("#password1").val($.sha1(password+timestamp+e.salt))
                    $("#loginForm").ajaxSubmit(function(e){
                        console.log(e)
                        layer.msg(e.msg);
                        if(e.code === 0){
                            setTimeout(function(){
                                window.location.href='/admin'
                            },500)
                        }
                    });
                }
            })
        })
    })
</script>
</body>
</html>
